/*
 * FileName:    CommonDownLoadAction.java
 * Description: 共通ダウンロードAction
 * History:     2011-01-21 (廖宝俊) 1.0 Create
 */
package com.sn.system.file.download;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.opensymphony.xwork2.ActionSupport;

public class CommonDownLoadAction extends ActionSupport {
	
	private String fileName;
	
	private String inputPath;

	public InputStream getInputStream() throws Exception {   
		String filePath="";
		int beginIndex=filePath.lastIndexOf("\\");
		fileName=filePath.substring(beginIndex+1, filePath.length());
		InputStream stream=new FileInputStream(filePath);   
		return stream;
    }   
	
	public String execute() throws Exception {   
		  
        return SUCCESS;   
  
    }   

    public void setInputPath(String value) {    
        inputPath = value;   
    }   
  
    public void setFileName(String fileName) {   
      
        this.fileName = fileName;    
    }    
  
    public String getDownloadFileName() {   
  
        String downFileName = fileName;   
  
        try {   
  
            downFileName = new String(downFileName.getBytes("Windows-31J"),"ISO8859-1");   
  
        } catch (UnsupportedEncodingException e) {   
            e.printStackTrace();    
        }   
  
        return downFileName;   
  
    }   
}
